import pymysql


# 数据库检查
def sqlCheck(sql, object):
    """

    :param sql: sql语句
    :param object: 项目“suki”，‘lookus’
    :return: 查询到的所有数据
    """
    conn = pymysql.connect(
        host='124.220.33.63',
        port=3306,
        user='root',
        passwd='jiaoyouhaha',
        database=object,
        charset='utf8')
    # 创建游标
    cmd = conn.cursor()
    # 准备并执行sql语句
    cmd.execute(query=sql)
    conn.commit()
    # 获取1条查询结果
    # results = cmd.fetchmany(n)[0][0]
    # 获取所有查询结果
    results = cmd.fetchall()
    conn.close()
    # print(results)
    return results


if __name__ == '__main__':
    sql = 'select * from matches where user_id1 = 427 or user_id2 = 427'
    print(sqlCheck(sql, 'suki'))
